package indi.gao.collection;

import com.alibaba.fastjson.JSONObject;
import indi.gao.model.Apple;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author :gaolei
 * @version :v1.0
 * @projectName :sprintboot
 * @description :
 * @createDate :2021/8/17 3:10 下午
 */
public class collectionTest {
    public static void main(String[] args) {
        ArrayList<Long> longs = new ArrayList<>();
        longs.add(123123412341234L);
        longs.add(123123412341234L);
        longs.add(2L);
        List<Long> collect = longs.stream().distinct().collect(Collectors.toList());
        System.out.println(JSONObject.toJSONString(collect));

        ArrayList<Apple> apples = new ArrayList<>();
        Apple ga = Apple.builder().name("ga1").price(1).build();
        Apple l = Apple.builder().name("ga").price(12).build();
        Apple lei = Apple.builder().name("ga0").price(1).build();
        apples.add(ga);
        apples.add(l);
        apples.add(lei);

        Map<String, Integer> collectApple = apples.stream().collect(Collectors.toMap(Apple::getName, Apple::getPrice));



        List<Apple> collect1 = apples.stream().distinct().collect(Collectors.toList());
        List<Apple> collect2 = apples.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Apple::getPrice))), ArrayList::new));

        System.out.println(JSONObject.toJSONString(collect1));
        System.out.println(JSONObject.toJSONString(collect2));

        System.out.println(325508/64%64);
    }
}
